#!/bin/bash
##统计线上数据库的*_users_foods_orders,并插入测试服务器的ops数据库
sqldatadir='sqldata'
mkdir -p $sqldatadir
sqldata=sqldata/`date '+%Y-%m-%d-%H-%M'`.txt
mysql -h 127.0.0.1 -uroot -p'password' -e "source /data/backup/tongji_day.sql" > $sqldata
#res=(`sed -n '2p' sql.txt`)
#res=`sed -n '2p' sql.txt|awk  '{print $10}'`
#echo ${res[@]};
cat ${sqldata}|awk 'NR>1'|while read line;
do
echo ${res[0]}
mysql -uroot -pmashangchi ops <<EOF
insert into ops_${res[0]} (quanpinyin,employerid,days,ordernumbers,foodnumbers,mabitotal,voucherstotal,alipaytotal,membercardtotal,weixinpaytotal,totals,total) VALUES("${res[0]}","${res[1]}","${res[2]}","${res[3]}","${res[4]}","${res[5]}","${res[6]}","${res[7]}","${res[8]}","${res[9]}","${res[10]}","${res[11]}");
EOF
done
